﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Grids.aspx.cs" Inherits="WebApplication2.Grids" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
            DataKeyNames="RegionID" DataSourceID="NorthwindDataSource" ForeColor="#333333" 
            GridLines="None" onrowupdating="GridView1_RowUpdating">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:CommandField ButtonType="Button" CancelText="No, don't do it" 
                    DeleteText="Delete Region" EditText="Modify Region" ShowDeleteButton="True" 
                    ShowEditButton="True" />
                <asp:BoundField DataField="RegionID" HeaderText="RegionID" ReadOnly="True" 
                    SortExpression="RegionID" />
                <asp:BoundField DataField="RegionDescription" HeaderText="RegionDescription" 
                    ReadOnly="True" SortExpression="RegionDescription" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
        <asp:SqlDataSource ID="NorthwindDataSource" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            DeleteCommand="DELETE FROM [Region] WHERE [RegionID] = @original_RegionID AND [RegionDescription] = @original_RegionDescription" 
            InsertCommand="INSERT INTO [Region] ([RegionID], [RegionDescription]) VALUES (@RegionID, @RegionDescription)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT * FROM [Region]" 
            UpdateCommand="UPDATE [Region] SET [RegionDescription] = @RegionDescription WHERE [RegionID] = @original_RegionID AND [RegionDescription] = @original_RegionDescription">
            <DeleteParameters>
                <asp:Parameter Name="original_RegionID" Type="Int32" />
                <asp:Parameter Name="original_RegionDescription" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="RegionID" Type="Int32" />
                <asp:Parameter Name="RegionDescription" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="RegionDescription" Type="String" />
                <asp:Parameter Name="original_RegionID" Type="Int32" />
                <asp:Parameter Name="original_RegionDescription" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <br />
        <br />
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
            AutoGenerateRows="False" CellPadding="4" DataKeyNames="RegionID" 
            DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
            Height="50px" Width="125px">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
            <EditRowStyle BackColor="#999999" />
            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
            <Fields>
                <asp:BoundField DataField="RegionID" HeaderText="RegionID" ReadOnly="True" 
                    SortExpression="RegionID" />
                <asp:BoundField DataField="RegionDescription" HeaderText="RegionDescription" 
                    SortExpression="RegionDescription" />
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                    ShowInsertButton="True" />
            </Fields>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            DeleteCommand="DELETE FROM [Region] WHERE [RegionID] = @original_RegionID AND [RegionDescription] = @original_RegionDescription" 
            InsertCommand="INSERT INTO [Region] ([RegionID], [RegionDescription]) VALUES (@RegionID, @RegionDescription)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT * FROM [Region]" 
            UpdateCommand="UPDATE [Region] SET [RegionDescription] = @RegionDescription WHERE [RegionID] = @original_RegionID AND [RegionDescription] = @original_RegionDescription">
            <DeleteParameters>
                <asp:Parameter Name="original_RegionID" Type="Int32" />
                <asp:Parameter Name="original_RegionDescription" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="RegionID" Type="Int32" />
                <asp:Parameter Name="RegionDescription" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="RegionDescription" Type="String" />
                <asp:Parameter Name="original_RegionID" Type="Int32" />
                <asp:Parameter Name="original_RegionDescription" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <br />
        <br />
        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
            BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" 
            CellPadding="2" DataSourceID="SqlDataSource2" 
            ForeColor="Black" GridLines="None" onrowcommand="GridView2_RowCommand">
            <AlternatingRowStyle BackColor="PaleGoldenrod" />
            <Columns>
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" 
                    SortExpression="CompanyName" />
                <asp:BoundField DataField="ContactName" HeaderText="ContactName" 
                    SortExpression="ContactName" />
                <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" 
                    SortExpression="ContactTitle" />
                
            </Columns>
            <FooterStyle BackColor="Tan" />
            <HeaderStyle BackColor="Tan" Font-Bold="True" />
            <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" 
                HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
            <SortedAscendingCellStyle BackColor="#FAFAE7" />
            <SortedAscendingHeaderStyle BackColor="#DAC09E" />
            <SortedDescendingCellStyle BackColor="#E1DB9C" />
            <SortedDescendingHeaderStyle BackColor="#C2A47B" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2 %>" 
            SelectCommand="SELECT [CompanyName], [ContactName], [ContactTitle] FROM [Customers] WHERE ([ContactName] LIKE '%' + @ContactName + '%')">
            <SelectParameters>
                <asp:Parameter DefaultValue="Matt" Name="ContactName" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
